﻿

using System;
using System.Collections.Generic;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Linq;
using Tong;
using JModel;


public partial class aspnet_testPargrameDir_site_Member_Admin_AddStu : System.Web.UI.Page
{
    public string str = "";
    /// <summary>
    /// 當前顯示的id
    /// </summary>
    string id = "1";

    /// <summary>
    /// 用於顯示資料
    /// </summary>
    public Tong.TongUse TextData = new Tong.TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    public string ho = "";

    /// <summary>
    /// 站点通用方法类
    /// </summary>
    public Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();


    //得到传入的栏目ID
    public String CloumnID = "1";

    /// <summary>
    /// 顯示當前欄目的簡介
    /// </summary>
    public string str1 = "";
    /// <summary>
    /// 資料表
    /// </summary>
    DataTable NewDt = new DataTable();
    /// <summary>
    /// 用于分頁的對像
    /// </summary>
    Tong.Fy.FenYe FY = new Tong.Fy.FenYe();
    /// <summary>
    /// 
    /// </summary>
    public string sud = "";

    /// <summary>
    /// 標題
    /// </summary>
    public string title = "";
    /// <summary>
    /// 表名
    /// </summary>
    public string tab = "Sys_WangZhanDeTue3aae";
    /// <summary>
    /// 学生实体
    /// </summary>
    public CX_Student stud = null;


    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 添加新记录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        decimal stid = 0;
        if (decimal.TryParse(stuid.Text, out stid))
        {
            JModel.DBEntities db = new JModel.DBEntities();

            if (db.CX_Student.Where(p => p.学号 == stid).Count() > 0)
            {
                TextData.ResonseAlert("已经存在的会员号,请不要重复输入");
                tt.Text = "已经存在的会员号,请不要重复输入";
            }
            else
            {

                db.CX_Student.AddObject(new CX_Student
                {

                    姓名 = xm.Text.Trim(),
                    联系方式 = lx.Text.Trim(),
                    学号 = decimal.Parse(stuid.Text)
                });

                db.SaveChanges();

                Response.Redirect(Request.Url+"?");
            }
            db.Connection.Close();
            db.Dispose();
        }
        else
        {
            TextData.ResonseAlert("会员号输入错误");
            tt.Text = "会员号输入错误";
        }



    }
}